package com.sunzz.springproj1114.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class MyController {
    @CrossOrigin
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(@RequestParam(defaultValue = "Guest") String name) {
        return "Hello, " + name + "!";
    }

    @CrossOrigin
    @RequestMapping("/getTime")
    @ResponseBody
    public String getTime() {
        Date date = new Date();
        return date.toString();
    }
}